//
// Created by 12992 on 24-10-13.
//

// You may need to build the project (run Qt uic code generator) to get "ui_FileSelector.h" resolved

#include <QHBoxLayout>
#include "fileselector.h"
#include "ui_FileSelector.h"
#include "uploadbar.h"
#include "dropupload.h"

namespace gui::widgets
{
    FileSelector::FileSelector(QWidget* parent) :
            QWidget(parent), ui(new Ui::FileSelector)
    {
        ui->setupUi(this);
        this->init_widgets();
        this->init_signals();
    }

    FileSelector::~FileSelector()
    {
        delete ui;
    }

    void FileSelector::init_widgets()
    {
        auto* hLayout = new QHBoxLayout(this);
        hLayout->setContentsMargins(0, 0, 0, 0);
        this->fileDropUpload = new DropUpload(this);
        QPalette pal = palette();
        pal.setColor(QPalette::Window, QColor(43, 45, 48, 200));
        this->fileDropUpload->setAutoFillBackground(true);
        this->fileDropUpload->setPalette(pal);

        this->uploadBar = new UploadBar(this);
        hLayout->addWidget(this->uploadBar);
        hLayout->addWidget(this->fileDropUpload);
        this->setLayout(hLayout);
    }

    void FileSelector::init_signals()
    {
        connect(this->fileDropUpload, &DropUpload::fileUploaded, this, &FileSelector::fileUpload);
        connect(this->uploadBar, &UploadBar::fileUploaded, this, &FileSelector::fileUpload);
        connect(this->uploadBar, &UploadBar::canceled, this, &FileSelector::canceled);
    }
} // gui::widgets
